package com.lili.operate.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lili.model.operate.DistributionCash;
import com.lili.operate.mapper.DistributionCashMapper;
import com.lili.operate.service.DistributionCashService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class DistributionCashServiceImpl implements DistributionCashService {
    @Autowired
    DistributionCashMapper distributionCashMapper;

    /**
     * 根据条件进行分页查询
     * @param map
     * @return
     */
    @Override
    public Page<DistributionCash> queryDistributionCash(Map map) {
        int current = 1;
        int size = 3;
        if(map.get("current") != null)
            current = Integer.parseInt(map.get("current").toString());
        if (map.get("size") != null)
            size = Integer.parseInt(map.get("size").toString());
        Page<DistributionCash> page = new Page<>(current,size);
        QueryWrapper<DistributionCash> wrapper = new QueryWrapper<>();
        if(map.get("distributionName") != null)
            wrapper.eq("distribution_name",map.get("distributionName").toString());
        if (map.get("sn") != null)
            wrapper.eq("sn",map.get("sn").toString());
        if (map.get("distributionCashStatus") != null)
            wrapper.eq("distribution_cash_status",map.get("distributionCashStatus").toString());
        distributionCashMapper.selectPage(page,wrapper);
        return page;
    }
}
